package com.zjp.birthdaymanager;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.ArrayList;

public class SendSmsActivity extends Activity implements View.OnClickListener{
    //发送短息按钮
    private Button mSendsms;
    //取消短信发送
    private Button mCancelSms;
    //输入的电话号码
    private EditText mInputPhone;
    //输入的短信内容
    private EditText mSmsContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_send_sms);

        mSendsms = (Button) findViewById(R.id.btn_sendsms);
        mCancelSms = (Button) findViewById(R.id.btn_cancelsms);
        mSendsms.setOnClickListener(this);
        mCancelSms.setOnClickListener(this);

        mInputPhone = (EditText) findViewById(R.id.et_inputphone);
        mSmsContent = (EditText) findViewById(R.id.et_smscontent);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_sendsms:
                String strPhone = mInputPhone.getText().toString().trim();
                String strSmsContent = mSmsContent.getText().toString().trim();

                if (TextUtils.isEmpty(strPhone) || TextUtils.isEmpty(strSmsContent)){
                    Toast.makeText(this,"电话和短信内容不能为空", Toast.LENGTH_SHORT);
                }else{
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("smsto:" + strPhone));
                    intent.putExtra("sms-sms", strSmsContent);
                    startActivity(intent);
                    //Toast.makeText(this, "发送成功", Toast.LENGTH_SHORT);
                    finish();

                }


                break;
            case R.id.btn_cancelsms:
                finish();
                break;
        }
    }
}
